package com.atguigu.juc;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

public class ReLock {

    public static void main(String[] args) {
        Phonee phonee = new Phonee();
        new Thread(() -> {
            phonee.sendSms();
        }).start();

        new Thread(()-> {

            phonee.sendEmail();
            System.out.println("我才开始发邮件");
        }).start();

    }
}

class Phonee{

    public synchronized void sendSms(){
        System.out.println(Thread.currentThread().getId() +"发短信");
        try {
            TimeUnit.SECONDS.sleep(4);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        sendEmail();
    }

    public synchronized void sendEmail(){
        System.out.println(Thread.currentThread().getId() + "发邮件");
    }
}